package leetcode.other;

import lombok.extern.slf4j.Slf4j;
import org.junit.Test;

/**
 * @author LiDong
 * @version 1.0.0
 * @createTime 2/20/2022 10:28 AM
 */
@Slf4j
public class Test0805 {

    @Test
    public void test(){
      log.info(String.valueOf(multiply(3,4)));
    }

    public int multiply(int A, int B) {
        if (A > B) {
            multiply(B, A);
        }
        if (A == 1) {
            return B;
        }
        if (A % 2 == 0) {
            return multiply(A >> 1, B) << 1;
        } else {
            return (multiply(A >> 1, B) << 1) + B;
        }


    }
}
